package info.opensoaring.server.jdo;

import info.opensoaring.api.igc.FlightOptimization;

import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Blob;
import com.google.appengine.api.users.User;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class Flight {

    @PrimaryKey
    private String hash;

    @Persistent
    private Date creationTime;

    @Persistent
    private Date lastUpdate;

    @Persistent
    private Date startTime;

    @Persistent
    private Date finishTime;

    @Persistent
    private User owner;

    @Persistent
    private Club club;

    @Persistent
    private Blob igcFlight;

    @Persistent
    private EncodedPath flightPath;

    @Persistent
    private List<FlightOptimization> optimizations;
    
    public Flight(String hash) {
	this.hash = hash;
    }

    public String getHash() {
	return hash;
    }

    public void setHash(String hash) {
	this.hash = hash;
    }

    public Date getCreationTime() {
	return creationTime;
    }

    public void setCreationTime(Date creationTime) {
	this.creationTime = creationTime;
    }

    public Date getLastUpdate() {
	return lastUpdate;
    }

    public void setLastUpdate(Date lastUpdate) {
	this.lastUpdate = lastUpdate;
    }

    public Date getStartTime() {
	return startTime;
    }

    public void setStartTime(Date startTime) {
	this.startTime = startTime;
    }

    public Date getFinishTime() {
	return finishTime;
    }

    public void setFinishTime(Date finishTime) {
	this.finishTime = finishTime;
    }

    public User getOwner() {
	return owner;
    }

    public void setOwner(User owner) {
	this.owner = owner;
    }

    public Club getClub() {
	return club;
    }

    public void setClub(Club club) {
	this.club = club;
    }

    public Blob getIgcFile() {
	return igcFlight;
    }

    public Blob getIgcFlight() {
        return igcFlight;
    }
    
    public void setIgcFlight(Blob igcFlight) {
	this.igcFlight = igcFlight;
    }

    public EncodedPath getFlightPath() {
        return flightPath;
    }

    public void setFlightPath(EncodedPath flightPath) {
        this.flightPath = flightPath;
    }

    public List<FlightOptimization> getOptimizations() {
        return optimizations;
    }

    public void setOptimizations(List<FlightOptimization> optimizations) {
        this.optimizations = optimizations;
    }

    public String toString() {
	return hash + " :: ";
    }
}
